package com.tongji.housediy.view
{   	
	import com.tongji.housediy.model.GoodsModel;
	import com.tongji.housediy.view.titlewindows.PicSelectComp;
	import com.tongji.housediy.vo.Picture;
	
	import flash.events.MouseEvent;
	
	import mx.binding.utils.BindingUtils;
	import mx.controls.Alert;
	import mx.events.ItemClickEvent;
	
	import org.robotlegs.mvcs.Mediator;
	
	
	/**
	 * 
	 * @author yanghanbing
	 * 2011/2/25
	 */ 
	public class PicSelectCompMediator extends Mediator
	{
		[Inject]
		public var view:PicSelectComp;
		
		[Inject]
		public var model:GoodsModel;
		public var defaultPic:String
		override public function onRegister():void
		{			
			view.pic.source = model.previewPicSrc;
			view.SelectColor.addEventListener(ItemClickEvent.ITEM_CLICK, changePicHandler);
		}
		
		private function changePicHandler(event:ItemClickEvent):void
		{
			if (model.picArray.length >= int(view.SelectColor.selectedValue))
				view.pic.source = (model.picArray.getItemAt(int(view.SelectColor.selectedValue) - 1) as Picture).pictureSrc;
		}
	}
}